package com.example.patternfactory0307.factoryPattern.abstractFactory;

/**
 * Created by huanglijun on 2019/3/7
 */
public class DemoTest {


    public static void main(String[] args) {
        GREEAirConditioner greeAirConditioner = new GREEAirConditioner();

        greeAirConditioner.reduceHeat();  //格力空调可以降温
        greeAirConditioner.warmUpHeat();  //格力空调可以升温


        MideaAirConditioner mideaAirConditioner = new MideaAirConditioner();
        mideaAirConditioner.reduceHeat();  //美的空调可以降温
        mideaAirConditioner.warmUpHeat();  //美的空调可以升温


        GREEWaterHeater greeWaterHeater = new GREEWaterHeater();
        greeWaterHeater.heatUpWater();     //格力热水器可以烧开水

        MideaWaterHeater mideaWaterHeater = new MideaWaterHeater();
        mideaWaterHeater.heatUpWater();    //美的热水器可以烧开水

        /**
         * 存在问题：
         * 1，使用每种品牌的冰箱 都要显示手动去创建这个品牌冰箱的对象
         * 2，各个不同品牌的冰箱 实际上有很多相同功能的  这个可以抽取
         */

        System.out.println("==========================");

        MideaFactory mideaFactory = new MideaFactory();
        //美的空调
        AirConditioner airConditioner = mideaFactory.createAirConditioner();
        airConditioner.reduceHeat();
        airConditioner.warmUpHeat();
        //美的热水器
        WaterHeater waterHeater = mideaFactory.createWaterHeater();
        waterHeater.heatUpWater();


        GREEFactory greeFactory = new GREEFactory();
        //格力热水器
        WaterHeater waterHeater1 = greeFactory.createWaterHeater();
        waterHeater1.heatUpWater();
        //格力空调
        AirConditioner airConditioner1 = greeFactory.createAirConditioner();
        airConditioner1.warmUpHeat();
        airConditioner1.reduceHeat();

        /**
         * 强转
         */
        GREEAirConditioner greeAirConditioner1 = (GREEAirConditioner)airConditioner1;
        greeAirConditioner1.x();
    }


}
